FROM 172.31.75.188/zhilink/ubuntu:14.04.1_v01
#FROM nginx-test:1.11.7 

#添加下载nginx php需要的包
#ADD http://downloads.zend.com/guard/7.0.0/zend-loader-php5.6-linux-x86_64.tar.gz .
#ADD http://am1.php.net/distributions/php-5.6.22.tar.gz .

#复制需要的安装包
COPY nginx-1.11.7.tar.gz .
COPY php-5.6.22.tar.gz .
COPY zend-loader-php5.6-linux-x86_64.tar.gz  .
COPY libiconv.so  /usr/local/lib 


#安装nginx+php依赖
RUN apt-get  update -y \
    && apt-get install  vim lsof  gcc build-essential  libtool libpcre3 libpcre3-dev  zlib1g-dev openssl  libxslt-dev libicu-dev libcurl3-openssl-dev libssl-dev   libxml2-dev libmcrypt-dev libjpeg-dev libpng-dev libfreetype6-dev libmcrypt-dev libxtst-dev libjpeg-dev libmcrypt-dev mysql-client -y  

#安装nginx
RUN cd / \
    && tar xf nginx-1.11.7.tar.gz \
    && cd  nginx-1.11.7 && ./configure --prefix=/usr/local/nginx && make && make install \ 
    && cp /usr/local/nginx/sbin/nginx /usr/sbin \
    && rm -rf /nginx-1.11.7* \
    && mkdir /usr/local/nginx/conf/vhost \
    && nginx -t 


#安装php
RUN  tar xf php-5.6.22.tar.gz && rm -rf php-5.6.22.tar.gz \
    && cd  php-5.6.22 \
    && ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc   --without-pear  --disable-phar --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --enable-intl --with-xsl ${PHP_Modules_Options} \
    && make ZEND_EXTRA_LIBS='-liconv'\
    && make install \
    && mkdir -p /usr/local/php/etc \
    && cd / \ 
    && tar zxf zend-loader-php5.6-linux-x86_64.tar.gz && rm -rf zend-loader-php5.6-linux-x86_64.tar.gz \
    && mkdir -p /usr/local/zend/ \
    && cp zend-loader-php5.6-linux-x86_64/ZendGuardLoader.so /usr/local/zend/ \ 
    && cp php-5.6.22/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm  \

    && chmod +x /etc/init.d/php-fpm \ 
    && cp  /usr/share/zoneinfo/Asia/Shanghai   /etc/localtime \
    && rm -rf /zend-loader-php5.6-linux-x86_64 /php-5.6.22  

#配置nginx php 
RUN mkdir -p /opt/www \
    && useradd www \
    && echo '<?php phpinfo();?>' >/opt/www/phpinfo.php \
    && echo 'hello nginx' >/opt/www/index.html

COPY nginx  /etc/init.d/nginx
COPY nginx.conf /usr/local/nginx/conf/
COPY default.conf /usr/local/nginx/conf/vhost/default.conf 
COPY php.ini /usr/local/php/etc/php.ini 
COPY php-fpm.conf /usr/local/php/etc/php-fpm.conf

ADD start.sh /start.sh

#启动
CMD ["/start.sh"]
